/**
 * 面试邀请页-外部
 */
import React from 'react';
import MetaTags from 'react-meta-tags';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Spin, Result } from 'antd';
import cn from 'classnames';
// import { useRequest, defaultFormatResult } from '@/hooks';
// import Header from '@/layouts/Header';
// import logo from '@/assets/logo.png';
// import { useCheckLogin } from '@/pages/RecruitEmail/hooks';
import { usePlatform } from './hooks';
// import { getInterviewEffective } from './service/interview';
import { Header } from './components';
import { Login, InterviewRegistration, InterviewUpdate, OldLogin } from './pc/components';
// import {
//     InterviewMobile,
//     LoginMobile,
//     RefuseMobile,
//     RegisterMobile,
//     LawPreviewMobile,
//     UpdateTimeMobile
// } from './mobile';
import {
    Refuse,
    UpdateTime,
    Login as LoginMobile,
    Register as RegisterMobile,
    Education,
    PersonInfo,
    SalaryIntension,
    LawPreviewMobile,
    BackgroundIntensions,
    BackgroundContacts,
    OldLoginMobile
} from './mobile';
import styles from './InterviewEntryPage.less';
import { InterviewOfferRefuse } from './mobile/containers';

const PAGE = {
    INTERVIEW: 'interview',
    UPDATE: 'changeInterview',
    REFUSE: 'refuse',
    LOGIN: 'login',
    REGISTER: 'register',
    DECLARE: 'declare',
    EDUCATION: 'education',
    PERSON: 'info',
    SALARY: 'intension',
    BackgroundIntensions: 'intensions',
    BackgroundContacts: 'contacts',
    SIGNIN: 'signin',
    OFFERREFUSE: 'offer_refuses',
    OLDLOGIN: 'login_old'
};

const InterviewEntryPage = ({ location }) => {
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    const { pathname, query } = location;
    console.log('entry-----', location);
    const { isMobile } = usePlatform();
    console.log('isMobile', isMobile);
    // const { data } = useRequest(() => getInterviewEffective(query?.id), {
    //     ...defaultFormatResult
    // });
    // const { isLogin, checkLoading } = useCheckLogin(query?.id, pathname);
    const isPage = page => {
        if (pathname.includes('recruitment')) {
            return pathname.endsWith(page);
        }
        return false;
    };
    const isOldLogin = () => !pathname.includes('recruitment') || pathname.includes('login_old');
    return (
        <>
            {!isMobile && <Header />}
            <div id="scrollContainer" className={cn(styles.pageWrap, { [styles.mobile]: isMobile })}>
                {/* {data === undefined && loading && (
                    <div style={{ padding: 50, display: 'flex', justifyContent: 'center' }}>
                        <Spin />
                    </div>
                )} */}
                {isMobile && (
                    <>
                        <MetaTags>
                            <title>微微科技官网</title>
                            <meta name="keywords" content="微微科技官网" />
                            <meta name="description" content="微微科技官网" />
                            <meta
                                name="viewport"
                                content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0"
                            />
                        </MetaTags>
                        {isPage(PAGE.REFUSE) && <Refuse />}
                        {isPage(PAGE.UPDATE) && <UpdateTime />}
                        {isPage(PAGE.LOGIN) && <LoginMobile />}
                        {isPage(PAGE.REGISTER) && <RegisterMobile />}
                        {isPage(PAGE.EDUCATION) && <Education />}
                        {isPage(PAGE.PERSON) && <PersonInfo />}
                        {isPage(PAGE.SALARY) && <SalaryIntension />}
                        {isPage(PAGE.DECLARE) && <LawPreviewMobile />}
                        {isPage(PAGE.BackgroundIntensions) && <BackgroundIntensions />}
                        {isPage(PAGE.BackgroundContacts) && <BackgroundContacts />}
                        {isPage(PAGE.OFFERREFUSE) && <InterviewOfferRefuse />}
                        {isOldLogin() && <OldLoginMobile />}
                    </>
                )}
                <>
                    {!isMobile && <>{isPage(PAGE.REGISTER) && <InterviewRegistration />}</>}
                    {!isMobile && <>{isPage(PAGE.LOGIN) && <Login />}</>}
                    {!isMobile && <>{isPage(PAGE.UPDATE) && <InterviewUpdate />}</>}
                    {!isMobile && <>{isOldLogin() && <OldLogin />}</>}
                </>
                {/* <>{isPage(PAGE.SIGNIN) && <InterviewSign />}</> */}
                {/* {data === 1 && <Result status="error" title="当前链接已失效！" />}
                {data === 0 && (
                    <>
                        {!isMobile && <>{isPage(PAGE.REGISTER) && <InterviewRegistration />}</>}
                        {!isMobile && <>{isPage(PAGE.LOGIN) && <Login />}</>}
                        {!isMobile && <>{isPage(PAGE.UPDATE) && <InterviewUpdate />}</>}
                    </>
                )} */}
                {/* <Spin spinning={checkLoading}>
                    {isLogin ? (
                        <>
                            {!isMobile && <>{isPage(PAGE.REGISTER) && <InterviewRegistration />}</>}

                            {!isMobile && <>{isPage(PAGE.UPDATE) && <InterviewUpdate />}</>}
                        </>
                    ) : (
                        <> {!isMobile && <>{isPage(PAGE.LOGIN) && <Login />}</>}</>
                    )}
                </Spin> */}
            </div>
        </>
    );
};

export default InterviewEntryPage;
